/**
 *
 * @param nums
 */
function sortedSquares(nums) {
    var length = nums.length - 1, r = length, l = 0;
    var res = [];
    while (r >= l) {
        if (nums[r] * nums[r] >= nums[l] * nums[l]) {
            res[length--] = nums[r] * nums[r--];
        }
        else {
            res[length--] = nums[l] * nums[l++];
        }
        console.log(r, l);
    }
    return res;
}
;
console.log(sortedSquares([-4, -1, 0, 3, 10]));
